package edu.hubu.CollectionTraverse;


public class ArrayTraverse {
    public static void main(String[] args) {
        //TODO:1.创建数组对象
        int[] arr = new int[5];

        //TODO:2.添加数据
        arr[0] = 1;
        arr[1] = 12;
        arr[2] = 9;
        arr[3] = 25;
        arr[4] = 6;

        //TODO:3.采用传统for循环遍历
        System.out.println("采用传统for循环遍历数组:");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + ", ");
        }
        System.out.println();

        //TODO:4.采用增强for循环遍历
        System.out.println("采用增强for循环遍历数组:");
        for (int a : arr) {
            System.out.print(a + ", ");
        }
        System.out.println();
    }
}
